//
//  HomeHotPictureTableViewCell.m
//  GLGW_Shoping
//
//  Created by yang on 2018/11/30.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "HomeHotPictureTableViewCell.h"

@interface HomeHotPictureTableViewCell ()
{
    GLGWImageView * typeImageView;
    GLGWLabel * titleNameLabel;
    GLGWLabel * timeLabel;
}
@end

@implementation HomeHotPictureTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        GLGWView * bankgroundView = [[GLGWView alloc] initWithInSuperView:self.contentView];
        bankgroundView.backgroundColor = [UIColor whiteColor];
        [bankgroundView setViewShadowWidth:3.0 theCornerRadius:3.0];
        [bankgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView.mas_left).offset(kWidthProportion_In_iPhoneTriploid(15));
            make.right.equalTo(self.contentView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
            make.top.equalTo(self.contentView.mas_top).offset(kHeightProportion_In_iPhoneTriploid(10));
            make.bottom.equalTo(self.contentView.mas_bottom).offset(-kHeightProportion_In_iPhoneTriploid(10));
        }];
        
        typeImageView = [[GLGWImageView alloc] initInSuperView:bankgroundView];
        typeImageView.imageName = @"icon_tupianqiugou";
        [typeImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.equalTo(bankgroundView);
            make.width.equalTo(@(kWidthProportion_In_iPhoneTriploid(40)));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(40)));
        }];
        
        titleNameLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(16) theColor:kColor_Rule_Black inSuperView:bankgroundView];
        titleNameLabel.numberOfLines = 0;
        titleNameLabel.text = @"碳钢弯头 Q235 70*20*40 1件 头 Q235 70*20*40 1件 头 Q235 70*20*40 1件 头 Q235 70*20*40 1件 头 Q235 70*20*40 1件";
        [titleNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(bankgroundView.mas_left).offset(kWidthProportion_In_iPhoneTriploid(20));
            make.top.equalTo(bankgroundView.mas_top).offset(kHeightProportion_In_iPhoneTriploid(18));
            make.right.equalTo(bankgroundView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(9));
        }];
        
        GLGWImageView * pictureImageView;
        for (int i =0; i<3; i++) {
            pictureImageView = [[GLGWImageView alloc] initInSuperView:bankgroundView];
            [pictureImageView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(bankgroundView.mas_left).offset(kWidthProportion_In_iPhoneTriploid(20)+kWidthProportion_In_iPhoneTriploid(90)*i);
                make.top.equalTo(self->titleNameLabel.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(10));
                make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(80)));
                make.width.equalTo(@(kWidthProportion_In_iPhoneTriploid(80)));
            }];
            pictureImageView.backgroundColor = kRandomColor;
        }
        
        timeLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(12) theColor:[UIColor colorWithHexString:@"#999999"] inSuperView:bankgroundView];
        timeLabel.textAlignment = NSTextAlignmentRight;
        timeLabel.attributedText = [GLGWLabel bllChangeStr:@"11月28日 | 30分钟截止" changewithStr:@"30分钟截止" changeColoer:[UIColor colorWithHexString:@"#FF374F"] withFont:SYSTEMFONT(12)];
        [timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(bankgroundView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
            make.bottom.equalTo(bankgroundView.mas_bottom).offset(-kHeightProportion_In_iPhoneTriploid(10));
            make.top.equalTo(pictureImageView.mas_bottom).offset(kWidthProportion_In_iPhoneTriploid(10));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(17)));
        }];
    }
    return self;
}


- (void)setPurchaseListModel:(PurchaseAllListDataInfosModel *)purchaseListModel
{
    _purchaseListModel = purchaseListModel;
    if (purchaseListModel.type == 1) { // 1、普通求购 2、定金求购、3. 图片求购 4 委托求购 5长期求购'
        typeImageView.imageName = @"icon_putongqiugou";
    } else if (purchaseListModel.status == 2) {
        typeImageView.imageName = @"icon_dingjinqiugou";
    } else if (purchaseListModel.status == 3) {
        typeImageView.imageName = @"icon_tupianqiugou";
    } else if (purchaseListModel.status == 4) {
        typeImageView.imageName = @"icon_weituoqiugou";
    } else if (purchaseListModel.status == 5) {
        typeImageView.imageName = @"icon_changqiqiugou";
    }
    
    titleNameLabel.text = purchaseListModel.titleWord;
    NSString *creatTimeStr = [NSString stringWithFormat:@"%@ | ",purchaseListModel.createTime]; // @"11月28日 | 4家已报价 | 1天5小时35分26秒截止"
    NSString *endTimeStr = [NSString stringWithFormat:@""];
    NSString *str6 = [NSString stringWithFormat:@"%@%@",creatTimeStr,endTimeStr];
    timeLabel.attributedText = [GLGWLabel bllChangeStr:str6 changewithStr:endTimeStr changeColoer:[UIColor colorWithHexString:@"#FF374F"] withFont:SYSTEMFONT(12)];
}

@end
